package de.baumann.browser.activitys;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatDelegate;
import android.view.KeyEvent;
import android.widget.TextView;

import de.baumann.browser.base.BaseOdinActivity;
import de.baumann.browser.base.BasePresenter;
import de.baumann.browser.fragments.Fragment_settings;
import de.baumann.browser.R;
import de.baumann.browser.iview.IBaseView;
import de.baumann.browser.units.IntentUnit;

@Deprecated
public class SettingsActivity extends BaseOdinActivity {
    private Fragment_settings fragment;

    @SuppressWarnings("ConstantConditions")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        super.onCreate(savedInstanceState);
    }


    @Override
    public String getTitleText() {
        return getString(R.string.setting_label);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_settings;
    }

    @Override
    protected void initView() {
        initToolbar(findViewById(R.id.commToolBar),findViewById(R.id.commTitle));
        fragment = new Fragment_settings();
        getFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).commit();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected IBaseView createView() {
        return null;
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            IntentUnit.setDBChange(fragment.isDBChange());
            IntentUnit.setSPChange(fragment.isSPChange());
            finish();
            return true;
        }

        return false;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == IntentUnit.REQUEST_CLEAR) {
            if (resultCode == Activity.RESULT_OK && data != null && data.hasExtra(Settings_ClearActivity.DB_CHANGE)) {
                fragment.setDBChange(data.getBooleanExtra(Settings_ClearActivity.DB_CHANGE, false));
            }
        }
    }

    public static void startSettingActivity(Context context){
        context.startActivity(new Intent(context,SettingsActivity.class));
    }

}
